<?php

namespace app\common\enum\order;

use MyCLabs\Enum\Enum;

/**
 * 订单奖励类型
 */
class OrderAwardEnum extends Enum
{
    // 分销奖励
    const AGENT = 10;

    const AWARD_TIMING_PAYED = 10;    // 付款后发放奖励
    const AWARD_TIMING_CONFIRMED = 20;  // 确认收货后发放奖励
    /**
     * 获取订单类型值
     */
    public static function data()
    {
        return [
            self::AGENT => [
                'name' => '分销奖励',
                'value' => self::AGENT,
            ],
            self::AWARD_TIMING_PAYED => [
                'name' => '付款后发放奖励',
                'value' => self::AWARD_TIMING_PAYED,
            ],
            self::AWARD_TIMING_CONFIRMED => [
                'name' => '确认收货后发放奖励',
                'value' => self::AWARD_TIMING_CONFIRMED,
            ],
        ];
    }

    /**
     * 获取订单类型名称
     */
    public static function getTypeName()
    {
        static $names = [];

        if (empty($names)) {
            foreach (self::data() as $item)
                $names[$item['value']] = $item['name'];
        }

        return $names;
    }

}